package com.totem.base.config;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class SpringDocConfig {
    @Bean
    public OpenAPI openAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("接口文档")
                        .description("基于SpringDoc的在线接口文档")
                        .version("0.1.0"));
    }

    @Bean
    public GroupedOpenApi adminApi() {
        return GroupedOpenApi.builder()
                .group("admin")
                //.packagesToScan("com.totem.base.model", "com.totem.admin.api", "com.totem.customer.api","com.totem.customer.vo")
                .pathsToMatch("/admin/**")
                .build();
    }
    @Bean
    public GroupedOpenApi customerApi() {
        return GroupedOpenApi.builder()
                .group("customer")
                //.packagesToScan("com.totem.base.model", "com.totem.admin.api", "com.totem.customer.api","com.totem.customer.vo")
                .pathsToMatch("/customer/**")
                .build();
    }
    @Bean
    public GroupedOpenApi favoriteApi() {
        return GroupedOpenApi.builder()
                .group("favorite")
                .pathsToMatch("/favorite/**")
                .build();
    }
    @Bean
    public GroupedOpenApi trackApi() {
        return GroupedOpenApi.builder()
                .group("track")
                .pathsToMatch("/track/**")
                .build();
    }
    @Bean
    public GroupedOpenApi orderApi() {
        return GroupedOpenApi.builder()
                .group("order")
                .pathsToMatch("/order/**")
                .build();
    }
    @Bean
    public GroupedOpenApi walletApi() {
        return GroupedOpenApi.builder()
                .group("wallet")
                .pathsToMatch("/wallet/**")
                .build();
    }
    @Bean
    public GroupedOpenApi fundApi() {
        return GroupedOpenApi.builder()
                .group("fund")
                .pathsToMatch("/fund/**")
                .build();
    }
    @Bean
    public GroupedOpenApi productApi() {
        return GroupedOpenApi.builder()
                .group("product")
                .pathsToMatch("/product/**")
                .build();
    }
    @Bean
    public GroupedOpenApi subscribeApi() {
        return GroupedOpenApi.builder()
                .group("subscribe")
                .pathsToMatch("/subscribe/**")
                .build();
    }
}
